package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.RFC;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.GenerateRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.ChooseEditRFCDialog;

public class LoadDialogPanelListener implements ActionListener {

	private GenerateRFCPanel generateRFCPanel;
	private ChooseEditRFCDialog chooseEditRFCDialog;

	public LoadDialogPanelListener(GenerateRFCPanel generateRFCPanel,
			ChooseEditRFCDialog chooseEditRFCDialog) {

		this.chooseEditRFCDialog = chooseEditRFCDialog;
		this.generateRFCPanel = generateRFCPanel;
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		RFC rfc = 	chooseEditRFCDialog.getDisplayTable().getSelectedRFCinTable();


		this.generateRFCPanel.getDatainputPanel().setupInputFields();
		this.generateRFCPanel.getDatainputPanel().loadExistingData(rfc);
		
		this.generateRFCPanel.getFunctionPanel().changeButtonstate();
		
		this.generateRFCPanel.revalidate();
		this.chooseEditRFCDialog.dispose();

	}

}
